package com.appbee.core.server.guice;

import com.appbee.adminshell.server.AdminFilter;
import com.appbee.core.server.Log4jInit;
import com.appbee.core.server.dao.access.CrudAccessControl;
import com.appbee.core.server.dao.access.impl.AnnotationCrudAccessControl;
import com.appbee.core.server.requestfactory.AppRequestFactoryServlet;
import com.appbee.core.server.twig.CustomObjectDatastore;
import com.appbee.core.server.twig.RenameEntity;
import com.appbee.media.server.guice.DatastoreServiceProvider;
import com.appbee.songs.server.FixSongIndex;
import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.users.UserService;
import com.google.code.twig.ObjectDatastore;
import com.google.inject.servlet.ServletModule;

public class AppServletModul extends ServletModule
{

	@Override
	protected void configureServlets()
	{
		bind(Log4jInit.class).asEagerSingleton();
		bind(ObjectDatastore.class).to(CustomObjectDatastore.class);
		bind(DatastoreService.class).toProvider(DatastoreServiceProvider.class);
		bind(CrudAccessControl.class).to(AnnotationCrudAccessControl.class);
		bind(UserService.class).toProvider(UserServiceProvider.class);
		
		serve("/gwtRequest").with(AppRequestFactoryServlet.class);
		filter("/admin/*", "/Admin.html").through(AdminFilter.class);
		serve("/song/fixindex").with(FixSongIndex.class);
		serve("/admin/renameEntities").with(RenameEntity.class);
	}

}
